﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.ZY
{
    class Class2
    {

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            //赔付100%保额,合同终止
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                double x = ppa.GetDutyTotalValue("生存保险金");

                double m = ppa.TotalFee - x;

                da.Value = ppa.Amount > m ? ppa.Amount : m;

                ppa.IsCurrentFinish = true;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            //赔付100%保额,合同终止
            if (ppa.SchemePeriodActing.InsurantStates.Contains("男性/女性重疾"))
            {
                ppa.SchemePeriodActing.InsurantStates.Add("重疾");
                da.Value = ppa.Amount * 0.5;                         //设置赔偿金
                ppa.IsCurrentFinish = true;          //设置终止期

                ppa.Tag = "豁免保费";

            }

        }

        public void Calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外残疾"))
            {
                string level = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("意外残疾等级").ToString();

                double x = 0d;

                if (level == "第一级")
                {
                    x = ppa.Amount ;
                }
                else if (level == "第二级")
                {
                    x = ppa.Amount * 0.75;
                }
                else if (level == "第三级")
                {
                    x = ppa.Amount * 0.5;
                }

                da.Value = x;

            }
        }

        public void Calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("烧烫伤")) 
            { 
                string s = ppa.PolicyActing.SchemeActing.GetAuxConfigValue("烧烫伤部位").ToString(); 
                
                if (s == "头部等于3%") 
                { 
                    da.Value = ppa.Amount * 0.4; 
                } else if (s == "头部等于3%并引致视力或眼球受损") 
                { 
                    da.Value = ppa.Amount * 0.6; 
                } else if (s == "头部＞3%且＜8%") 
                { 
                    da.Value = ppa.Amount * 0.75; 
                } else if (s == "头部＞3%且＜8%并引致视力或眼球受损") 
                { 
                    da.Value = ppa.Amount; 
                } else if (s == "头部≥8%") 
                { 
                    da.Value = ppa.Amount; 
                } else if (s == "肢体＞10%且＜20%") 
                {
                    da.Value = ppa.Amount * 0.5; 
                } else if (s == "肢体＞10%且＜20%并累及手掌Ⅲ度烧伤") 
                { 
                    da.Value = ppa.Amount * 0.75; 
                } else if (s == "肢体≥20%") 
                { 
                    da.Value = ppa.Amount; 
                } 
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故") )
            {
                string a = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年限"];

                int receiveAge = 0;

                if (a == "50岁")
                    receiveAge = 50;
                else if (a == "55岁")
                    receiveAge = 55;
                else if (a == "60岁")
                    receiveAge = 60;
                else if (a == "65岁")
                    receiveAge = 65;

                if (ppa.Age < receiveAge)
                {
                    da.Value = ppa.TotalFee * 1.1;
                }
                else if (ppa.Age >= receiveAge && ppa.Age <= 85)
                {
                    int c=85-ppa.Age;
                    double v=0;
                    double t = 0;
                    v=ppa.PolicyActing.Policy.Amount * 0.03;

                    for(int i=ppa.Age+1 ;i<=85;i++)
                    {
                        t += (i-receiveAge) * v;
                    }
                    da.Value = ppa.Amount +t;
                }
                ppa.IsCurrentFinish = true;
            }

        }
    }
}
